Ok minor changes.
authorMark Crichton <crichton@src.gnome.org>
Mon, 19 Jul 1999 02:13:34 +0000 (02:13 +0000)
committerMark Crichton <crichton@src.gnome.org>
Mon, 19 Jul 1999 02:13:34 +0000 (02:13 +0000)
Ok minor changes.

No longer make a version.h, and cleaned up some code here and there, and added
a quickie dirty-hack rotation function.  However, it rotates at the origin.
Is this what we want?  Or do we want a rotate w.r.t. the center of the pixbuf?

Anyone.

Mark

demos/testpixbuf.c
gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/gdk-pixbuf.c
gdk-pixbuf/gdk-pixbuf.h
gdk-pixbuf/io-bmp.c

index e81d4607c103d8877e27b0d7b38d23533304621f..97a82f74a5f70a9fc7ae70ee2019caed2ae84197 100644 (file)
@@ -1,6 +1,6 @@
 
-/* GTK - The GIMP Toolkit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+/* testpixbuf -- test program for gdk-pixbuf code
+ * Copyright (C) 1999 Mark Crichton, Larry Ewing
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Boston, MA 02111-1307, USA.
  */
 
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-
-/* Note: these #includes differ slightly from the testrgb.c file included
-   in the GdkRgb release. */
-
-/* For gettimeofday */
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -161,6 +149,7 @@ main (int argc, char **argv)
   for (i = 1; i < argc; i++)
     {
       pixbuf = gdk_pixbuf_load_image (argv[i]);
+      pixbuf = gdk_pixbuf_rotate(pixbuf, 42.0);
       
       if (pixbuf)
        {
index 84a01ba01aaa3a6fa2fc0bba06d26b09fea32584..713e451121f40635a4733b1dfef3a34982c9fe67 100644 (file)
@@ -1,3 +1,19 @@
+1999-07-18  Mark Crichton  <crichton@gimp.org>
+
+       * configure.in: removed version.h. 
+
+       * src/gdk-pixbuf-io.c (pixbuf_check_tiff): Minor readability
+       improvements.
+
+1999-07-17  Mark Crichton  <crichton@gimp.org>
+
+       * src/gdk-pixbuf.c: Removed gdk_pixbuf_free, redundant code.
+       (gdk_pixbuf_rotate): Added pixbuf rotation code.
+       (gdk_pixbuf_scale): Changed // comments to /* */
+
+       * src/gdk-pixbuf.h (gdk_pixbuf_destroy): Added gdk_pixbuf_destroy
+       function to header.
+
 1999-07-16  Larry Ewing  <lewing@gimp.org>
 
        * src/testpixbuf.c (expose_func): reverted the expose everything
index 53da897cbae9536b7e8cd3181a1072b9012280de..cdb0007fbbdc36f852e2e2cf7853578c0f74f544 100644 (file)
@@ -47,10 +47,16 @@ pixbuf_check_tiff (unsigned char *buffer, int size)
        if (size < 10)
                return FALSE;
 
-       if (buffer [0] == 'M' && buffer [1] == 'M' && buffer [2] == 0 && buffer [3] == 0x2a)
+       if (buffer [0] == 'M' && 
+           buffer [1] == 'M' && 
+           buffer [2] == 0   && 
+           buffer [3] == 0x2a)
                return TRUE;
 
-       if (buffer [0] == 'I' && buffer [1] == 'I' && buffer [2] == 0x2a && buffer [3] == 0)
+       if (buffer [0] == 'I' && 
+           buffer [1] == 'I' && 
+           buffer [2] == 0x2a && 
+           buffer [3] == 0)
                return TRUE;
        
        return FALSE;
@@ -139,11 +145,13 @@ image_file_format (const char *file)
 static void
 image_handler_load (int idx)
 {
-       char *module_name = g_strconcat ("pixbuf-", file_formats [idx].module_name, NULL);
+       char *module_name;
        char *path;
        GModule *module;
        void *load_sym, *save_sym;
-       
+       
+       module_name = g_strconcat ("pixbuf-", 
+                                  file_formats [idx].module_name, NULL);
        path = g_module_build_path (PIXBUF_LIBDIR, module_name);
        g_free (module_name);
 
index 0068c163d6b68b7faa9e2f904abb73817e830048..1ab110557429fdeab2c4d1bef01900da6fe475e4 100644 (file)
@@ -6,25 +6,26 @@
  */
 #include <config.h>
 #include <glib.h>
+#include <math.h>
 #include <libart_lgpl/art_misc.h>
 #include <libart_lgpl/art_rgb_affine.h>
 #include <libart_lgpl/art_alphagamma.h>
 #include "gdk-pixbuf.h"
 
 
-static void
+void
 gdk_pixbuf_destroy (GdkPixBuf *pixbuf)
 {
-       art_pixbuf_free (pixbuf->art_pixbuf);
-       g_free (pixbuf);
+     art_pixbuf_free (pixbuf->art_pixbuf);
+     g_free (pixbuf);
 }
 
 void
 gdk_pixbuf_ref (GdkPixBuf *pixbuf)
 {
-    g_return_if_fail (pixbuf != NULL);
-    
-    pixbuf->ref_count++;
+     g_return_if_fail (pixbuf != NULL);
+     
+     pixbuf->ref_count++;
 }
 
 void
@@ -38,14 +39,6 @@ gdk_pixbuf_unref (GdkPixBuf *pixbuf)
        gdk_pixbuf_destroy (pixbuf);
 }
 
-void
-gdk_pixbuf_free (GdkPixBuf *pixbuf)
-{
-     art_free(pixbuf->art_pixbuf->pixels);
-     art_pixbuf_free_shallow(pixbuf->art_pixbuf);
-     g_free(pixbuf);
-}
-
 GdkPixBuf *
 gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
 {
@@ -64,7 +57,7 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
     affine[0] = w / (double)(pixbuf->art_pixbuf->width);
     affine[3] = h / (double)(pixbuf->art_pixbuf->height);
 
-    //    rowstride = w * pixbuf->art_pixbuf->n_channels;
+    /*    rowstride = w * pixbuf->art_pixbuf->n_channels; */
     rowstride = w * 3;
 
     pixels = art_alloc (h * rowstride);
@@ -73,7 +66,7 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
                           affine, ART_FILTER_NEAREST, alphagamma);
 
     if (pixbuf->art_pixbuf->has_alpha)
-      // should be rgba
+      /* should be rgba */
       art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
     else 
       art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
@@ -84,5 +77,43 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
     return pixbuf;
 }
 
+GdkPixBuf *
+gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle)
+{
+     GdkPixBuf *rotate;
+     art_u8 *pixels;
+     gint rowstride, w, h;
+     gdouble rad;
+     double affine[6];
+     ArtAlphaGamma *alphagamma = NULL;
+     ArtPixBuf *art_pixbuf = NULL;
+
+     w = pixbuf->art_pixbuf->width;
+     h = pixbuf->art_pixbuf->height;
+
+     rad = M_PI * angle / 180.0;
+
+     affine[0] = cos(rad);
+     affine[1] = sin(rad);
+     affine[2] = -sin(rad);
+     affine[3] = cos(rad);
+     affine[4] = affine[5] = 0;
+
+     /* rowstride = w * pixbuf->art_pixbuf->n_channels; */
+     rowstride = w * 3;
+
+     pixels = art_alloc (h * rowstride);
+     art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
+                           pixbuf->art_pixbuf,
+                           affine, ART_FILTER_NEAREST, alphagamma);
+      if (pixbuf->art_pixbuf->has_alpha)
+      /* should be rgba */
+      art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
+    else 
+      art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
 
+    art_pixbuf_free (pixbuf->art_pixbuf);
+    pixbuf->art_pixbuf = art_pixbuf;
 
+    return pixbuf;
+}
index 371def2da8177fc28a82d8b3665b8774f48ce4b3..a1886468d1de0abe9aed8f127f8c39790f9ab9e3 100644 (file)
@@ -16,7 +16,8 @@ void       gdk_pixbuf_ref        (GdkPixBuf *pixbuf);
 void       gdk_pixbuf_unref      (GdkPixBuf *pixbuf);
 GdkPixBuf *gdk_pixbuf_duplicate  (GdkPixBuf *pixbuf);
 GdkPixBuf *gdk_pixbuf_scale     (GdkPixBuf *pixbuf, gint w, gint h);
+GdkPixBuf *gdk_pixbuf_rotate     (GdkPixBuf *pixbuf, gdouble angle);
 
-void      gdk_pixbuf_free       (GdkPixBuf *pixbuf);
+void      gdk_pixbuf_destroy    (GdkPixBuf *pixbuf);
 
 #endif /* _GDK_PIXBUF_H_ */
index ecd7f38281642cb544d80b05ebb15ac8acbd99aa..61955995488b4b414fa0f68401e844be5310ffac 100644 (file)
@@ -25,8 +25,9 @@
 #include <glib.h>
 #include "gdk-pixbuf.h"
 #include "gdk-pixbuf-io.h"
+#include "io-bmp.h"
 
-/* Loosely based off the BMP loader from The GIMP */
+/* Loosely based off the BMP loader from The GIMP, hence it's complexity */
 
 /* Shared library entry point */
 GdkPixBuf *image_load(FILE * f)